home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 1997
/
HAM Radio 1997.iso
/
vcls
/
moden
/
adinidb.int
< prev
next >
Wrap
Text File
|
1996-04-08
|
5KB
|
152 lines
{$G+,X+,F+}
{Conditional defines that may affect this unit}
{$I AWDEFINE.INC}
{*********************************************************}
{* ADINIDB.PAS 1.01 *}
{* Copyright (c) TurboPower Software 1995 *}
{* All rights reserved. *}
{*********************************************************}
unit AdIniDB;
{-Delphi INI database component}
interface
uses
{-----RTL}
SysUtils,
Classes,
Messages,
WinTypes,
DsgnIntf,
Forms,
Controls,
{-----APD}
OoMisc,
{$IFNDEF UseAPWDLL}
AwIniDB,
{$ENDIF}
AdMisc,
AdExcept,
AdDataB,
AdFldLst;
{$IFDEF UseAPWDLL}
{$I AWINIDB.PA0}
{$ENDIF}
const
DefDBName = 'DATABASE.INI';
type
{.Z+}
{property editor for list of database fields}
TDBFieldListProperty = class(TPropertyEditor)
procedure Edit; override;
function GetAttributes : TPropertyAttributes; override;
function GetValue : String; override;
end;
{property editor for drop-down list of indexable fields}
TIndexedFieldProperty = class(TStringProperty)
function GetAttributes : TPropertyAttributes; override;
function GetEditLimit : Integer; override;
procedure GetValues(Proc : TGetStrProc); override;
procedure SetValue(const Value : String); override;
end;
{.Z-}
{a database key string}
TDBKeyStr = String[MaxIndexLen];
{INI database component}
TApdCustomIniDBase = class(TComponent)
protected {private}
{.Z+}
DB : PIniDatabase; {record passed to DLL calls}
FRecordList : TStringList; {for returning record lists}
FFieldList : TDBFieldList; {list of database fields}
Scratch : Pointer; {scratch record for passing into DLL}
Changed : Boolean; {TRUE if database data has changed}
FOpen : Boolean; {TRUE if database has been opened}
FFileName : String; {file name, used mostly at design time}
FIndexedField : TDBIndexedField; {name of field used for index}
CustComponent : Boolean;
{Property read/write methods}
procedure SetFileName(const NewName : String);
{-Update the database's file name. If open, reopen with the new name}
procedure SetOpen(const OpenIt : Boolean);
{-Open or close the database}
procedure SetFieldList(const Fields : TDBFieldList);
{-Set the database's list of fields}
procedure SetIndexedField(const S : TDBIndexedField);
{-Set the name of the field used to index the database}
function GetRecordList : TStrings;
{-Returns the key strings for each record in the database}
function GetNumRecs : Integer;
{-Returns the number of records in the database}
{utility}
procedure AssureOpen;
{-Make sure that the database is open, otherwise raise an exception}
procedure ClearFieldList;
{-Remove all fields in the field list}
procedure DefaultIndexed;
{-Default the FIndexedField property to the first indexable field in the list}
{streaming}
procedure ReadFields(Reader : TReader);
{-Reads the database field list from a stream}
procedure WriteFields(Writer : TWriter);
{-Writes the database field list to a stream}
procedure DefineProperties(Filer : TFiler); override;
{-Define methods for reading and writing field list}
protected
property FileName : String
read FFileName write SetFileName;
property FieldList : TDBFieldList
read FFieldList write SetFieldList;
property IndexedField : TDBIndexedField
read FIndexedField write SetIndexedField;
public
{Creation/destruction}
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
{.Z-}
function KeyExists(const Key : TDBKeyStr) : Boolean;
{-Return TRUE if an entry with an index of 'Name' exists}
procedure AddRecord(var Rec);
{-Add a record to the database}
procedure UpdRecord(const Key : TDBKeyStr; var Rec);
{-Update a record in the database}
procedure DelRecord(const Key : TDBKeyStr);
{-Remove a record from the database}
procedure GetRecord(const Key : TDBKeyStr; var Rec);
{-Get a record from the database}
procedure WriteToIni(var Rec; const Section, IniFile : String);
{-Write the record to a user-specified .INI file}
procedure ReadFromIni(var Rec; const Section, IniFile : String);
{-Read the record from a user-specified .INI file}
property RecordList : TStrings
read GetRecordList;
property NumRecs : Integer
read GetNumRecs;
property Open : Boolean
read FOpen write SetOpen;
end;
TApdIniDBase = class(TApdCustomIniDBase)
published
property FileName;
property FieldList;
property IndexedField;
end;